﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using System.Xml;

namespace GameVLTK
{
    public class GameStateMainMenu : GameState
    {
        private MainMenu _MainMenu;

        public MainMenu MainMenu
        {
            get { return _MainMenu; }
            set { _MainMenu = value; }
        }
 
        /// <summary>
        /// Khởi tạo màn hình Menu từ tập tin XML
        /// </summary>
        /// <param name="content"></param>
        /// <param name="strXml"></param>
        public GameStateMainMenu(ContentManager content, string strXml)
        {
            this.Doc= new XmlDocument();
            this.Doc.Load(strXml);

            XmlNode nRoot = this.Doc.DocumentElement;

            //Khởi tạo ảnh background
            Texture2D[] textures = new Texture2D[1];
            textures[0] = content.Load<Texture2D>(nRoot.Attributes["Path-Images"].Value + "BackGround");
            this.BackGround = new MySprite(textures, new Vector2(0, 0));

            //Tính toán frame Seq
            int []frameSeq= {0};
            this.BackGround.FrameSequence = frameSeq;

            //Khởi tạo Main Menu
            this.MainMenu = new MainMenu(content, this.Doc);

        }

        public override void Update(GameTime gameTime)
        {
            this.BackGround.Update(gameTime);

            this.MainMenu.Update(gameTime);
        }


        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            this.BackGround.Draw(gameTime, spriteBatch);

            this.MainMenu.Draw(gameTime, spriteBatch);

        }
    }
}
